package com.weixin.engine.interceptor;

import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 测试
 *
 * @author wangchunhui
 * @date 2022/2/17 16:14
 */
//@Configuration
@AllArgsConstructor
public class AuthorityInterceptorConfig implements WebMvcConfigurer {

    private final AuthorityInterceptor1 authorityInterceptor1;
    private final AuthorityInterceptor2 authorityInterceptor2;
    private final AuthorityInterceptor3 authorityInterceptor3;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        String[] swaggerExcludes =
                new String[]{"/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/error", "/csrf"};

        registry.addInterceptor(authorityInterceptor1)
                .addPathPatterns("/**")
                .excludePathPatterns(swaggerExcludes);

        registry.addInterceptor(authorityInterceptor2)
                .addPathPatterns("/**")
                .excludePathPatterns(swaggerExcludes);

        registry.addInterceptor(authorityInterceptor3)
                .addPathPatterns("/**")
                .excludePathPatterns(swaggerExcludes);
    }
}